package com.seuic.socketassistant

import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.PreferenceManager

/**
 * Application
 *
 * @author KP(zhn2174@gmail.com)
 * @since 1.0.0
 */
class MyApplication : Application() {

    companion object {
        /**
         * Application 单例
         */
        private var instance: MyApplication?= null

        /**
         * 获取Application实例
         * @return ScheduleApplication Application实例
         */
        fun instance() = instance!!
    }

    override fun onCreate() {
        super.onCreate()
        instance = this

        AppCompatDelegate.setDefaultNightMode(
            PreferenceManager.getDefaultSharedPreferences(this)
                .getString("theme_mode", "-1")?.toInt() ?: -1
        )
    }

}